<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="提现订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNo">
              {{model.orderNo}}
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="提现类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reviewComment">
              押金退款
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="提现金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="amountMoney">
              {{model.amountMoney}}元
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="申请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
              {{model.createTime}}
            </a-form-model-item>
          </a-col>
          <a-col :span="12">

          </a-col>
<!--          <a-col :span="12">
            <a-form-model-item label="申请用户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountName">
              {{model.accountName}}
            </a-form-model-item>
          </a-col>-->

          <a-col :span="24">
            <a-form-model-item label="审核备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reviewComment">
              <a-input v-model="model.reviewComment" placeholder="请输入审核备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
<!--            <a-form-model-item label="微信支付订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paymentNo">
              <a-input v-model="model.paymentNo" placeholder="请输入微信支付订单号"  ></a-input>
            </a-form-model-item>-->

            <a-col :span="4">

            </a-col>
             <a-button type="primary" @click="searchQuery" >审核通过</a-button>
             <a-button type="primary" @click="searchReset" style="margin-left: 8px">审核不通过</a-button>
            <a-col :span="4">

            </a-col>
          </a-col>

        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

import { httpAction, getAction, postAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'RentalWithdrawalReviewForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        projectNameList:[
          {name:'包月',id:1},
          {name:'包季',id:2},
          {name:'半年',id:3},
          {name:'包年',id:4}
        ],
        isStartdata:[
          {name:'是',id:1},
          {name:'否',id:2},
        ],
        typelistdata:[],
        confirmLoading: false,
        validatorRules: {
          withdrawalStatus:[{ required: true, message: '请选择提现状态!' }],
        },
        url: {
          edit: "/rental/rentalWithdrawalReview/review",
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      this.gettypelist()
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      searchQuery(){
        this.model.withdrawalStatus=2
         this.submitForm()
      },
      searchReset(){
        this.model.withdrawalStatus=3
        this.submitForm()
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
              httpurl+=this.url.edit;
               method = 'post';
            let data={
              id: this.model.id,
              reviewComment: this.model.reviewComment,
              withdrawalStatus: this.model.withdrawalStatus
            }
            postAction(httpurl,data).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
      gettypelist(){
        let that=this;
        httpAction(this.url.typelist,{pageSize:100,pageNo:1},'get').then((res)=>{
             this.typelistdata=res.result.records

            }).finally(() => {

            })
      }
    }
  }
</script>